# -*- coding: utf-8 -*-
# @project: huawang-api20230914
# @file： MemberManagepage.py
# @Time：2023/9/20 14:43
# @Author：liaogan
import allure

from common.commin.basePage import BasePage
from time import sleep

"""会员列表页面"""


class MemberList(BasePage):
    """会员列表页面"""

    @allure.step('编辑会员列表页面')
    def Edit_MemberList(self, phone, name, remrks, User_point):
        self.input_text(self.searchpone_input, phone, desc="输入要搜索的信息")
        self.click_element(self.search_type, desc="点击搜索类型")
        self.click_element(self.selector_phone, desc="选择类型为手机号")
        self.click_element(self.search_button, desc="点击搜索")
        self.click_element(self.edit_button, desc="点击编辑")
        sleep(2)
        self.input_text(self.name_input, name, desc="输入姓名")
        self.input_text(self.User_remarks_input, remrks, desc="输入备注")
        self.input_text(self.User_points_input, User_point, desc="输入用户积分")
        self.click_element(self.verify_button, desc="点击确认")
        sleep(1)
        return MemberList()

    @allure.step('获取Tips信息')
    def Get_Tips(self):
        return self.get_element_text(self.get_tips, desc="获取修改成功Tips提示")  # 获取删除成功tips


"""会员等级操作"""
class MemberGrade(BasePage):

    @allure.step('添加会员等级')
    def add_member_grade(self, grade_name, Purchase_points_back, Direct_back_integration,
                         Interval_regression_integral, Points_deduction_ratio, accumulative_consumption):
        self.click_element(self.new_button, desc="点击新增")
        self.input_text(self.grade_name, grade_name, desc="等级名称")
        self.input_text(self.Purchase_points_back, Purchase_points_back, desc="自购返积分")
        self.input_text(self.Direct_back_integration, Direct_back_integration, desc="直推返积分")
        self.input_text(self.Interval_regression_integral, Interval_regression_integral, desc="间推返积分")
        self.input_text(self.Points_deduction_ratio, Points_deduction_ratio, desc="积分抵扣比例")
        self.input_text(self.accumulative_consumption, accumulative_consumption, desc="累计消费")
        self.click_element(self.verify_button, desc="点击确认")
        sleep(1)
        return MemberGrade()

    @allure.step('删除会员等级')
    def delete_menbergrade(self):
        self.click_element(self.delete_menbergrade_button, desc="删除会员等级操作")
        sleep(1)
        self.click_element(self.verify_button1, desc="点击确认")
        sleep(1)
        return MemberGrade()

    # 获取删除成功tips
    @allure.step('获取Tips信息')
    def Get_Tips(self):
        return self.get_element_text(self.get_tips, desc="获取新增成功Tips提示")
